package model.backoffice

import model.postgresql.PgBaseEvent
import zio.json.{DeriveJsonDecoder, DeriveJsonEncoder, JsonDecoder, JsonEncoder}

case class ItemAndInfo(event: PgBaseEvent, info: ResponseUserInfo)
case class ResponseUserInfo(firstName: String, lastName: String)
case class JsonResponse(items: List[ItemAndInfo], query: JsonGeneralFields)

object JsonResponse {
  given JsonDecoder[ItemAndInfo] = DeriveJsonDecoder.gen[ItemAndInfo]
  given JsonEncoder[ItemAndInfo] = DeriveJsonEncoder.gen[ItemAndInfo]

  given JsonDecoder[ResponseUserInfo] = DeriveJsonDecoder.gen[ResponseUserInfo]
  given JsonEncoder[ResponseUserInfo] = DeriveJsonEncoder.gen[ResponseUserInfo]

  given JsonDecoder[JsonResponse] = DeriveJsonDecoder.gen[JsonResponse]
  given JsonEncoder[JsonResponse] = DeriveJsonEncoder.gen[JsonResponse]
}
